package com.atguigu.eduservice.service.impl;

import com.atguigu.eduservice.entity.TOrder;
import com.atguigu.eduservice.mapper.TOrderMapper;
import com.atguigu.eduservice.service.TOrderService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 订单 服务实现类
 * </p>
 *
 * @author testjava
 * @since 2020-08-01
 */
@Service
public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> implements TOrderService {

    @Override
    public boolean isBuyCourse(String courseId, String memberId) {
        QueryWrapper<TOrder> wrapper = new QueryWrapper<>();
        wrapper.eq("course_id",courseId);
        wrapper.eq("member_id",memberId);
        wrapper.eq("status",1);
        int count = baseMapper.selectCount(wrapper);
        if (count>0){//已经支付
            return true;
        }else{
            return false;

        }
    }
}
